package modle;

import java.sql.Timestamp;
import java.util.List;
import java.util.Set;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * A data access object (DAO) providing persistence and search support for Club
 * entities. Transaction control of the save(), update() and delete() operations
 * can directly support Spring container-managed transactions or they can be
 * augmented to handle user-managed Spring transactions. Each of these methods
 * provides additional information for how to configure it for the desired type
 * of transaction control.
 * 
 * @see modle.Club
 * @author MyEclipse Persistence Tools
 */

public class ClubDAO extends BaseHibernateDAO {
	private static final Logger log = LoggerFactory.getLogger(ClubDAO.class);
	// property constants
	public static final String MANGER = "manger";
	public static final String CLUB_WORLD_NAME = "clubWorldName";
	public static final String CLUB_LOCAL_NAME = "clubLocalName";
	public static final String LANGUAGE_CODE = "languageCode";
	public static final String PROVINCE_CODE = "provinceCode";
	public static final String CITY_CODE = "cityCode";
	public static final String LOCATION = "location";
	public static final String DESCRIPTION = "description";
	public static final String HOMEPAGE = "homepage";
	public static final String SOCIAL_MEDIA_GROUP = "socialMediaGroup";
	public static final String SOCIAL_MEDIA_GROUPPAGE = "socialMediaGrouppage";
	public static final String MOTTO = "motto";
	public static final String COLOUR_CODE1 = "colourCode1";
	public static final String COLOUR_CODE2 = "colourCode2";
	public static final String COLOUR_CODE3 = "colourCode3";
	public static final String SMALL_GRAPHIC_ICON = "smallGraphicIcon";
	public static final String MEDIUM_GRAPHIC_ICON = "mediumGraphicIcon";
	public static final String LARGE_GRAPHIC_ICON = "largeGraphicIcon";
	public static final String WEB_NOTES = "webNotes";
	public static final String MEMBER_NOTES = "memberNotes";
	public static final String ADMIN_NOTES = "adminNotes";
	public static final String MEETING_NOTES = "meetingNotes";
	public static final String TICK_PUBLIC_MEETING = "tickPublicMeeting";
	public static final String TICK_VERIFIED = "tickVerified";
	public static final String TICK_SUSPENDED = "tickSuspended";
	public static final String TICK_HIDDEN = "tickHidden";
	public static final String USER_CR = "userCr";
	public static final String USER_MOD = "userMod";

	public void save(Club transientInstance) {
		log.debug("saving Club instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(Club persistentInstance) {
		log.debug("deleting Club instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Club findById(java.lang.Integer id) {
		log.debug("getting Club instance with id: " + id);
		try {
			Club instance = (Club) getSession().get("modle.Club", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Club instance) {
		log.debug("finding Club instance by example");
		try {
			List results = getSession().createCriteria("modle.Club").add(
					Example.create(instance)).list();
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Club instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Club as model where model."
					+ propertyName + "= ?";
			Query queryObject = getSession().createQuery(queryString);
			queryObject.setParameter(0, value);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByManger(Object manger) {
		return findByProperty(MANGER, manger);
	}

	public List findByClubWorldName(Object clubWorldName) {
		return findByProperty(CLUB_WORLD_NAME, clubWorldName);
	}

	public List findByClubLocalName(Object clubLocalName) {
		return findByProperty(CLUB_LOCAL_NAME, clubLocalName);
	}

	public List findByLanguageCode(Object languageCode) {
		return findByProperty(LANGUAGE_CODE, languageCode);
	}

	public List findByProvinceCode(Object provinceCode) {
		return findByProperty(PROVINCE_CODE, provinceCode);
	}

	public List findByCityCode(Object cityCode) {
		return findByProperty(CITY_CODE, cityCode);
	}

	public List findByLocation(Object location) {
		return findByProperty(LOCATION, location);
	}

	public List findByDescription(Object description) {
		return findByProperty(DESCRIPTION, description);
	}

	public List findByHomepage(Object homepage) {
		return findByProperty(HOMEPAGE, homepage);
	}

	public List findBySocialMediaGroup(Object socialMediaGroup) {
		return findByProperty(SOCIAL_MEDIA_GROUP, socialMediaGroup);
	}

	public List findBySocialMediaGrouppage(Object socialMediaGrouppage) {
		return findByProperty(SOCIAL_MEDIA_GROUPPAGE, socialMediaGrouppage);
	}

	public List findByMotto(Object motto) {
		return findByProperty(MOTTO, motto);
	}

	public List findByColourCode1(Object colourCode1) {
		return findByProperty(COLOUR_CODE1, colourCode1);
	}

	public List findByColourCode2(Object colourCode2) {
		return findByProperty(COLOUR_CODE2, colourCode2);
	}

	public List findByColourCode3(Object colourCode3) {
		return findByProperty(COLOUR_CODE3, colourCode3);
	}

	public List findBySmallGraphicIcon(Object smallGraphicIcon) {
		return findByProperty(SMALL_GRAPHIC_ICON, smallGraphicIcon);
	}

	public List findByMediumGraphicIcon(Object mediumGraphicIcon) {
		return findByProperty(MEDIUM_GRAPHIC_ICON, mediumGraphicIcon);
	}

	public List findByLargeGraphicIcon(Object largeGraphicIcon) {
		return findByProperty(LARGE_GRAPHIC_ICON, largeGraphicIcon);
	}

	public List findByWebNotes(Object webNotes) {
		return findByProperty(WEB_NOTES, webNotes);
	}

	public List findByMemberNotes(Object memberNotes) {
		return findByProperty(MEMBER_NOTES, memberNotes);
	}

	public List findByAdminNotes(Object adminNotes) {
		return findByProperty(ADMIN_NOTES, adminNotes);
	}

	public List findByMeetingNotes(Object meetingNotes) {
		return findByProperty(MEETING_NOTES, meetingNotes);
	}

	public List findByTickPublicMeeting(Object tickPublicMeeting) {
		return findByProperty(TICK_PUBLIC_MEETING, tickPublicMeeting);
	}

	public List findByTickVerified(Object tickVerified) {
		return findByProperty(TICK_VERIFIED, tickVerified);
	}

	public List findByTickSuspended(Object tickSuspended) {
		return findByProperty(TICK_SUSPENDED, tickSuspended);
	}

	public List findByTickHidden(Object tickHidden) {
		return findByProperty(TICK_HIDDEN, tickHidden);
	}

	public List findByUserCr(Object userCr) {
		return findByProperty(USER_CR, userCr);
	}

	public List findByUserMod(Object userMod) {
		return findByProperty(USER_MOD, userMod);
	}

	public List findAll() {
		log.debug("finding all Club instances");
		try {
			String queryString = "from Club";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public Club merge(Club detachedInstance) {
		log.debug("merging Club instance");
		try {
			Club result = (Club) getSession().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(Club instance) {
		log.debug("attaching dirty Club instance");
		try {
			getSession().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Club instance) {
		log.debug("attaching clean Club instance");
		try {
			getSession().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}